#include<iostream>
#include<vector>

using namespace std;

vector<vector<int>> edges;
vector<int> visited;
bool valid = true;

void dfs(int u) {
    visited[u] = 1;
    for (int v: edges[u]) {
        if (visited[v] == 0) {
            dfs(v);
            if (!valid) {
                return;
            }
        }
        else if (visited[v] == 1) {
            valid = false;
            return;
        }
    }
    visited[u] = 2;
}

int main(){
	int numCourses, len;
	cin>>numCourses>>len;
	vector<vector<int>> prerequisites(len, vector<int>(2));
	for(int i=0;i<len;i++){
		cin>>prerequisites[i][0]>>prerequisites[i][1];
	}
	
	edges.resize(numCourses);
    visited.resize(numCourses);
    for (const auto& info: prerequisites) {
        edges[info[1]].push_back(info[0]);
    }
    for (int i = 0; i < numCourses && valid; ++i) {
        if (!visited[i]) {
            dfs(i);
        }
    }
    
    if(valid){
    	cout<<"true";
	}else {
		cout<<"false";
	}

    return 0;
} 
